package com.example.benefitcommunity.config;


import com.example.benefitcommunity.interceptor.JWTInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author makejava
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    /**
     * 添加拦截器配置
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new JWTInterceptor())
                //拦截所有请求，通过判断token是否合法来决定是否需要登录
                .addPathPatterns("/**")
                //所有用户都放行登录接口
                .excludePathPatterns("/bcUser/**", "/swagger-resources/**", "/swagger-ui/**", "/v3/**", "/upload/**");
    }
}
